﻿<UserControl x:Class="Views.ViewSegSelection"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:VMtxgar="clr-namespace:OMANE.Modules.TauxGarantis.ViewModels"
             DataContext="{Binding Source={x:Static VMtxgar:Locator.ViewModelSegSelectionStatic}}"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>

        <CollectionViewSource x:Key="CollViewSegmentsPossiblesNonRetenus" Source="{Binding SegmentsPossiblesNonRetenus}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Value.chOutil.Format.typeAff.Name"></PropertyGroupDescription>
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
        <CollectionViewSource x:Key="CollViewSegmentsRetenus" Source="{Binding SegmentsRetenus}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Value.chOutil.Format.typeAff.Name"></PropertyGroupDescription>
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>

    </UserControl.Resources>


    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="5"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>            
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition Width="5"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></GridSplitter>
        <GridSplitter Grid.Row="1" Grid.ColumnSpan="3" HorizontalAlignment="Stretch"></GridSplitter>
        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="27"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Style="{DynamicResource OMANE_labelTitre}" Margin="0">Variables disponibles</Label>
            
            <ListView Grid.Row="1" x:Name="PossibleNonRetenue"
                      AllowDrop="True"
                      DragDrop.Drop="lstPossibleNonRetenue_Drop"
                      ItemsSource="{Binding Source={StaticResource CollViewSegmentsPossiblesNonRetenus}}"
                      ItemTemplate="{DynamicResource CorrespondanceItemTemplate}"
                      ItemContainerStyle="{DynamicResource PossibleNonRetenueStyle}">
                <ListView.Resources>
                    <Style x:Key="PossibleNonRetenueStyle" TargetType="{x:Type ListViewItem}">
                       <Style.Setters>
                            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="lstPossibleNonRetenue_PreviewMouseLeftButtonDown" />
                       </Style.Setters>
                    </Style>
                    <DataTemplate x:Key="CorrespondanceItemTemplate">
                        <TextBlock Text="{Binding Value.description}" />
                    </DataTemplate>
                </ListView.Resources>                
                <ListView.GroupStyle>
                    <GroupStyle ContainerStyle="{StaticResource ListViewOMANE_GroupItemStyle}" />
                </ListView.GroupStyle>
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="FrameworkElement.Visibility" Value="Collapsed" />
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridView.Columns>
                            <GridViewColumn Header="A">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Margin="0,0,5,0" Source="{Binding Value.chOutil.Format.typeAff.Name , Converter={StaticResource TypeNameToIconConverter}}"></Image>
                                            <TextBlock FontWeight="Regular" Text="{Binding Key}"></TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView.Columns>
                    </GridView>
                </ListView.View>
            </ListView>
            
        </Grid>
        <Grid Grid.Column="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="27"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Style="{DynamicResource OMANE_labelTitre}">Variables de segmentation</Label>
            <ListView Grid.Row="1" x:Name="Retenue" 
                    AllowDrop="True"
                    DragDrop.Drop="lstRetenue_Drop"
                    ItemsSource="{Binding Source={StaticResource CollViewSegmentsRetenus}}"
                    ItemContainerStyle="{DynamicResource RetenueItemStyle}">
                <ListView.Resources>
                    <Style x:Key="RetenueItemStyle" TargetType="{x:Type ListViewItem}">
                        <Style.Setters>
                        <EventSetter Event="PreviewMouseLeftButtonDown" Handler="lstRetenue_PreviewMouseLeftButtonDown" />
                        </Style.Setters>
                    </Style>
                </ListView.Resources>
                <ListView.GroupStyle>
                    <GroupStyle ContainerStyle="{StaticResource ListViewOMANE_GroupItemStyle}" />
                </ListView.GroupStyle>
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="FrameworkElement.Visibility" Value="Collapsed" />
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridView.Columns>
                            <GridViewColumn Header="A" Width="400">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Margin="0,0,5,0" Source="{Binding Value.chOutil.Format.typeAff.Name , Converter={StaticResource TypeNameToIconConverter}}"></Image>
                                            <TextBlock FontWeight="Regular" Text="{Binding Key}"></TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView.Columns>
                    </GridView>
                </ListView.View>
            </ListView>
        </Grid>
        <Grid Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="3">
            <Grid.RowDefinitions>
                <RowDefinition Height="27"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" FontWeight="Bold">Visualisation des segments</Label>
            <DataGrid xml:lang="fr-FR"
                      LoadingRow="DataGrid_LoadingRow"
                      Grid.Row="0"
                      Grid.RowSpan="2"
                      Background="White"
                      Visibility="{Binding isSegmentationVisible}"
                      Style="{StaticResource DataGridStyle1}"
                      ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle1}"
                      FontWeight="Normal"
                      ItemsSource="{Binding TraitReqSegmentation.DataTableResultat}" 
                      CellStyle="{DynamicResource DataGridCellStyle1}"	
					  IsReadOnly="True"
                      SelectionMode="Single" 
					  ItemsPanel="{DynamicResource ItemsPanelTemplate1}" 
					  RowHeaderStyle="{DynamicResource DataGridRowHeaderStyle1}"></DataGrid>
        </Grid>
    </Grid>
</UserControl>
